package com.wlyy.his.controller.registration;

import com.wlyy.his.bean.register.vo.PatientDetailVo;
import com.wlyy.his.common.api.CommonResult;
import com.wlyy.his.ze.api.ZeGuoNeiApiService;
import com.wlyy.his.ze.bean.base.BASEINFO;
import com.wlyy.his.ze.bean.request.RENYUANMXCX_IN_request;
import com.wlyy.his.ze.bean.response.RENYUANMXCX_OUT;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author: 10097
 * @date: 2021/9/1 18:48
 * @description:
 */
@RestController
@RequestMapping("patient")
public class HisPatientController {

    /**
     * 患者详细信息查询
     * 可用于查询病案号
     *
     * @param cardType 证件类型 1身份证 2病案号
     * @param cardNo 证件号码
     */
    @GetMapping("detail/cx")
    public CommonResult<List<PatientDetailVo>> patientDetailCx(String cardType, String cardNo){
        RENYUANMXCX_IN_request request = new RENYUANMXCX_IN_request();
        BASEINFO baseinfo = new BASEINFO();
        //默认0就可以了 测试过不同的分院都可以查询到 信息相同
        baseinfo.setFENYUANDM("0");
        request.setBASEINFO(baseinfo);
        request.setCHAXUNLX(cardType);
        request.setCHAXUNHM(cardNo);
        //默认0全部
        request.setBINGRENLB("0");
        RENYUANMXCX_OUT zc00524 = ZeGuoNeiApiService.patientDetailZC00524(request);
        if (null != zc00524.getBINGRENXX()) {
            List<PatientDetailVo> detailVos = zc00524.getBINGRENXX().stream().map(z -> new PatientDetailVo(cardType, cardNo, z.getJIUZHENKH(), z.getBINGANH())).collect(Collectors.toList());
            return CommonResult.success(detailVos);
        }
        return CommonResult.success(Collections.emptyList());
    }

}
